/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyBean;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author amaster
 */
public class CategoryBean {

    public String getCategoryTable() {
        String table = "<table width='500'> <tr>";
        try {
            Connection con = MyConnection.getConnection();
            Statement selectSt = con.createStatement();
            ResultSet rs = selectSt.executeQuery("Select * from [mobile].[dbo].[hangSX]");
            while (rs.next()) {
                table += "<td><a href='ListBook.jsp?cat="+rs.getInt("hangID")+"'>" + rs.getString("tenHang") + "</td>";
            }
        } catch (ClassNotFoundException ex) {
            return ex.getMessage();
        } catch (SQLException ex) {
            return ex.getMessage();
        }
        table += "</tr></table>";
        return table;
    }
}
